package com.chiaching.framwork.core.handler.security;

import com.chiaching.framwork.domian.constant.CoreConstant;
import com.chiaching.framwork.utils.CookieUtil;
import com.chiaching.framwork.utils.RedisUtils;
import com.chiaching.framwork.utils.SpringContextUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jiajing.he
 * @date 2021/7/27 下午2:50
 */
public class SuperMallLogoutHandler implements LogoutHandler {
    @Override
    public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) {
        SpringContextUtil.getBean(RedisUtils.class).del(CookieUtil.getValueInCookies(httpServletRequest, CoreConstant.USER_TOKEN));
    }
}
